#include <iostream>
using namespace std;
#define MVNum 50

bool visited[MVNum];//访问标志数组，其初值为false
void Initialize(int n)
{
    for (int i = 0; i < n; i++)
    {
        visited[i] = false;
    }
}

void DFS_AM(int str[][MVNum], int v, int n)
{
    cout << v << " ";
    visited[v] = true;
    for (int w = 0; w < n; w++)
    {
        if (str[v][w] != 0 && (!visited[w]))
        {
            DFS_AM(str, w, n);
        }
    }
}

int main()
{
    int n;
    int str[MVNum][MVNum];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            scanf("%d", &str[i][j]);
        }
    }
    Initialize(n);
    DFS_AM(str, 0, n);
    return 0;
}